<template>
  <div>
    <!-- 加载动画 -->
    <div
      v-if="loadings"
      v-loading="loadings"
      style="width: 100%; height: 100vh"
      element-loading-text="拼命加载中"
      element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0.8)"
    ></div>

    <!-- 内容 -->
    <div v-show="!loadings">
      <div class="warp">
        <!-- 副导航条 -->
        <div class="breadcrumb bg-white default-border">
          <el-breadcrumb separator-class="el-icon-arrow-right" class="ul">
            <el-breadcrumb-item class="li" :to="{ path: '/' }"
              >首页</el-breadcrumb-item
            >
            <el-breadcrumb-item
              class="li"
              :replace="true"
              :to="{ path: '/materials/lists' }"
            >
              各种资料
            </el-breadcrumb-item>
            <el-breadcrumb-item class="li">
              {{ ArticleJsonLists.title }}
            </el-breadcrumb-item>
          </el-breadcrumb>
        </div>

        <!-- 主体内容 -->
        <div class="artdetail-body mt-20" v-if="ArticleJsonLists">
          <div class="artdetail-main">
            <div class="bg-white artdetail-info default-border">
              <h1>{{ ArticleJsonLists.title }}</h1>
              <div>
                <span>{{ ArticleJsonLists.create_time }}</span>
                <span>{{ ArticleJsonLists.view }}人浏览</span>
              </div>
              <div class="contentbody" ref="cons">
                <!-- 内容区域 -->
              </div>
              <div class="jd-ad"></div>
            </div>

            <div class="article-comemnt bg-white default-border mb-20">
              <div class="comment-box pad-20">
                <div class="comment-form">
                  <div class="el-input">
                    <input
                      type="text"
                      autocomplete="off"
                      placeholder="请输入评论内容"
                      class="el-input__inner"
                    />
                  </div>
                  <button
                    disabled="disabled"
                    type="button"
                    class="el-button el-button--primary is-disabled"
                  >
                    <span>发送</span>
                  </button>
                </div>
                <div class="empty-comment">
                  <p>暂无评论,赶快抢占沙发吧</p>
                </div>
              </div>
            </div>
          </div>

          <!-- 右侧列表 -->
          <div class="artdetail-right">
            <div class="artdetail-special bg-white default-border pad-20 mt-20">
              <div class="artdetail-special-title">
                <p>易学啦课程</p>
                <a href="/video" class=""> 更多 </a>
              </div>
              <div class="line"></div>
              <div class="artdetail-special-list">
                <div class="jd-ad">
                  <div class="ads-info">
                    <div class="_1d006n6ggrg"></div>
                  </div>
                </div>
                <div class="li">
                  <a href="" class="">
                    <img
                      src="../assets/imgs/几何.jpg"
                      alt="高中数学解析几何专题教学视频"
                    />
                  </a>
                  <div class="artdetail-special-flex">
                    <p class="artdetail-special-list-title mt-10">
                      <a href="" class=""> 高中数学解析几何专题教学视频 </a>
                    </p>
                    <p class="artdetail-special-list-span">
                      <span>共小节</span>
                      <span>·</span>
                      <span>61691人已学习</span>
                    </p>
                    <div class="special-list-footer">
                      <a href="" class="">
                        <div class="dis-block special-list-btn">马上学习</div>
                      </a>
                    </div>
                  </div>
                </div>
                <div class="li">
                  <a href="" class="">
                    <img
                      src="../assets/imgs/几何.jpg"
                      alt="高中数学解析几何专题教学视频"
                    />
                  </a>
                  <div class="artdetail-special-flex">
                    <p class="artdetail-special-list-title mt-10">
                      <a href="" class=""> 高中数学解析几何专题教学视频 </a>
                    </p>
                    <p class="artdetail-special-list-span">
                      <span>共小节</span>
                      <span>·</span>
                      <span>61691人已学习</span>
                    </p>
                    <div class="special-list-footer">
                      <a href="" class="">
                        <div class="dis-block special-list-btn">马上学习</div>
                      </a>
                    </div>
                  </div>
                </div>
                <div class="li">
                  <a href="" class="">
                    <img
                      src="../assets/imgs/几何.jpg"
                      alt="高中数学解析几何专题教学视频"
                    />
                  </a>
                  <div class="artdetail-special-flex">
                    <p class="artdetail-special-list-title mt-10">
                      <a href="" class=""> 高中数学解析几何专题教学视频 </a>
                    </p>
                    <p class="artdetail-special-list-span">
                      <span>共小节</span>
                      <span>·</span>
                      <span>61691人已学习</span>
                    </p>
                    <div class="special-list-footer">
                      <a href="" class="">
                        <div class="dis-block special-list-btn">马上学习</div>
                      </a>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getArticleJsonData } from "../api/articles.js";
export default {
  data() {
    return {
      ArticleJsonLists: null,
      plists: null,
      loadings: true,
    };
  },
  methods: {
    getArticleJsonDataFun() {
      //获取数据遍历数组
      let idkeys = localStorage.getItem("Masterkey");
      console.log("idkeys", idkeys);

      getArticleJsonData({ id: idkeys }).then((data) => {
        // console.log(data.data);
        this.ArticleJsonLists = data.data;

        console.log("getArticleList==>", this.ArticleJsonLists);
        if (this.ArticleJsonLists) {
          setTimeout(() => {
            this.loadings = false;
          }, 1200);
        }
      });
    },
  },
  created() {
    this.getArticleJsonDataFun();
  },
  watch: {
    ArticleJsonLists: function () {
      let textList = this.ArticleJsonLists.content;
      this.$nextTick(() => {
        this.$refs.cons.innerHTML += textList;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
// 样式穿透
.breadcrumb ::v-deep .el-breadcrumb__inner.is-link:hover {
  color: #48c5a3;
  cursor: pointer;
}

.breadcrumb ::v-deep .is-link {
  color: #48c5a3;
  cursor: pointer;
}

.breadcrumb {
  margin-top: 10px;
  padding: 15px 10px;
  ul {
    li {
      &:before {
        font-family: iconfont !important;
        font-size: 14px;
        content: "/";
        margin: 0 4px 0 2px;
      }
      &:first-child {
        &:before {
          content: "";
        }
      }
      a {
        color: #48c5a3;
      }
    }
  }
}
.artdetail-body {
  display: flex;
  .artdetail-tab {
    width: 50px;
    padding: 10px;
    height: 340px;
    background: #fff;
    box-shadow: 0 0 24px 0 rgb(0 0 0 / 6%);
    color: #aaa;
    font-size: 12px;
    ul {
      padding: 0 6px;
      li {
        padding: 10px 0;
        cursor: pointer;
        &:last-of-type {
          border-bottom: 0;
        }
        i {
          font-size: 27px;
        }
        p {
          font-weight: 400;
          line-height: 17px;
        }
        &:hover {
          color: #48c5a3;
        }
      }
    }
  }
  .artdetail-main {
    margin: 0 24px;
    flex: 1;
    .artdetail-info {
      padding: 20px 30px 30px;
      margin-bottom: 20px;
      h1 {
        font-size: 30px;
        font-weight: 600;
        color: #333;
        letter-spacing: 1px;
        margin: 10px 0 18px;
      }
      span {
        font-size: 12px;
        font-weight: 400;
        color: #999;
        margin-right: 30px;
      }
    }
    .sidebar {
      padding: 15px;
    }
    .article-item {
      height: 110px;
      color: #333;
      border-bottom: 1px solid #eee;
      margin: 0 20px;
      display: flex;
      img {
        width: 120px;
        height: 81px;
        border-radius: 6px;
        margin: 15px 20px 0 0;
      }
      .article-info {
        flex: 1;
      }
    }
  }
  .artdetail-right {
    width: 320px;
    .artdetail-special {
      .line {
        margin: 15px 0;
      }
    }
  }
}
.text-center {
  text-align: center;
}
.contentbody {
  line-height: 1.6;
  font-size: 16px;
  color: #333;
  margin-top: 40px;
  p {
    font-size: 16px;
    letter-spacing: 0.4px;
    line-height: 30px;
    color: #606060;
    text-align: left;
    text-align: justify;
    word-wrap: break-word;
    margin-bottom: 20px;
    overflow: hidden;
  }
}
.contentbody audio,
.contentbody img,
.contentbody video {
  max-width: 100%;
  position: static !important;
}
.comment-box {
  .comment-form {
    display: flex;
    button {
      margin-left: 20px;
    }
  }
  .empty-comment {
    text-align: center;
    padding: 40px;
    color: #999;
  }
}
.comment-form {
  display: flex;
  padding: 10px;
}
.el-input {
  position: relative;
  font-size: 14px;
  display: inline-block;
  width: 100%;
}
.el-button {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #fff;
  border: 1px solid #dcdfe6;
  color: #606266;
  text-align: center;
  box-sizing: border-box;
  outline: 0;
  margin: 0;
  transition: 0.1s;
  font-weight: 500;
  padding: 12px 20px;
  font-size: 14px;
  border-radius: 4px;
}
.el-input__inner {
  background-color: #fff;
  background-image: none;
  border-radius: 4px;
  border: 1px solid #dcdfe6;
  box-sizing: border-box;
  color: #606266;
  display: inline-block;
  font-size: inherit;
  height: 40px;
  line-height: 40px;
  outline: 0;
  padding: 0 15px;
  width: 100%;
}
.el-button.is-disabled,
.el-button.is-disabled:focus,
.el-button.is-disabled:hover {
  color: #c0c4cc;
  cursor: not-allowed;
  background-image: none;
  background-color: #fff;
  border-color: #ebeef5;
}
.el-button--primary.is-disabled,
.el-button--primary.is-disabled:active,
.el-button--primary.is-disabled:focus,
.el-button--primary.is-disabled:hover {
  color: #fff;
  background-color: #a0cfff;
  border-color: #a0cfff;
}
/* 底部推荐预览列表 */
.sidebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  h3 {
    padding: 10px;
    font-size: 18px;
    font-weight: 600;
  }
}
.article-item {
  .item-title {
    margin: 24px 0 10px;
    font-size: 16px;
    font-weight: 600;
    line-height: 22px;
    display: flex;
    align-items: flex-start;
    .text {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      display: inline-block;
    }
  }
  .article-footer {
    font-size: 12px;
    font-weight: 400;
    color: #999;
    line-height: 17px;
    margin-top: 22px;
    display: flex;
    align-items: center;
    padding-right: 20px;
    span {
      margin-right: 30px;
    }
  }
}
/* 右侧列表 */
.artdetail-special {
  .artdetail-special-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    a {
      font-size: 14px;
      font-weight: 400;
      color: #999;
      line-height: 17px;
    }
  }
  .artdetail-special-list {
    .li {
      width: 100%;
      display: flex;
      font-size: 14px;
      font-weight: 400;
      color: #666;
      line-height: 20px;
      margin-bottom: 20px;
      img {
        width: 90px;
        height: 90px;
        border-radius: 4px;
        margin-right: 14px;
      }
    }
  }
}
.line {
  width: 100%;
  height: 1px;
  background-color: #eee;
}
.artdetail-special-list {
  .li {
    .artdetail-special-flex {
      display: flex;
      flex-direction: column;
    }
    .artdetail-special-list-title {
      font-size: 14px;
      font-weight: 600;
      display: flex;
      align-items: flex-start;
    }
    .artdetail-special-list-span {
      font-size: 12px;
      font-weight: 400;
      line-height: 17px;
      display: flex;
      align-items: center;
      margin: 2px 0 9px;
      span {
        color: #999;
        margin-right: 10px;
      }
    }
    .special-list-footer {
      font-size: 14px;
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
  }
}
.li {
  .special-list-footer {
    .special-list-btn {
      font-size: 12px;
      font-weight: 400;
      color: #f76447;
      padding: 3px 11px;
      background: rgba(247, 100, 71, 0.18824);
      border-radius: 12px;
    }
  }
}
</style>